package com.topone.dataObject;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.topone.Enum.BussinessStatusEnum;
import com.topone.Utils.EnumUnitl;
import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 商家信息
 * Created by Administrator on 2017/11/6,0006.
 */
@Entity
@DynamicUpdate
@Data
@Table(name = "bussiness")
@EntityListeners(AuditingEntityListener.class)
public class  Bussiness {
    @Id
    private String bussinessId; //商家Id
    @Column(name = "bussiness_code")
    private String bussinessCode;//商家code
    @Column(name = "openid")
    private String openid;
    @Column(name="bussiness_name")
    private String bussinessName; //商家名称
    @Column(name = "bussiness_user_name")
    private String bussinessUserName; //负责人姓名
    @Column(name = "bussiness_product")
    private String bussinessProduct;  //商家产品
    @Column(name = "bussiness_category")
    private String bussinessCategory; //商家种类（吃喝玩乐）
    @Column(name = "bussiness_rank")
    private String bussinessRank;  //业态（火锅，中式，日式）
    @Column(name = "bussiness_address")
    private String bussinessAddress; //商家地址
    @Column(name = "bussiness_phone")
    private String bussinessPhone;   //商家电话
    @Column(name ="bussiness_position" )
    private String bussinessPosition; //商家位置
    @Column(name = "bussiness_wechat_url")
    private String bussinessWechatUrl; //商家公众号地址
    @Column(name = "bussiness_wechat_name")
    private String  BussinessWechatName;
    @Column(name = "bussiness_introduce")
    private String bussinessIntroduce; //商家介绍
    @Column(name = "telephone")
    private String telephone;          //联系方式
    @Column(name = "bussiness_icon")
    private String bussinessIcon;     //商家图片
    @Column(name = "bussiness_password")
    private String bussinessPassword ="fanZone"; //密码
    @Column(name = "bussiness_status")
    private Integer bussinessStatus= BussinessStatusEnum.Prepare.getCode();  //商家状态
    @Column(name = "bussiness_credit")    //积分
    private Integer bussinessCredit= 0;
    @Column(name = "image_id")
    private String imageId;
    @Column(name = "balance")
    private BigDecimal balance;
    @Column(name = "total_fee")
    private BigDecimal totalFee;
    @Column(name = "create_time")
    @CreatedDate
    private Date createTime;
    @Column(name = "update_time")
    @LastModifiedDate
    private Date updateTime;

    @JsonIgnore
    public BussinessStatusEnum getBussinessStatusEnum(){

        return EnumUnitl.getByCode(bussinessStatus,BussinessStatusEnum.class);
    }

    public String getBussinessCode() {
        return bussinessCode;
    }

    public void setBussinessCode(String bussinessCode) {
        this.bussinessCode = bussinessCode;
    }

    public String getBussinessName() {
        return bussinessName;
    }

    public void setBussinessName(String bussinessName) {
        this.bussinessName = bussinessName;
    }

}
